package ${packageName}.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import ${packageName}.dto.${dbDto.className}Dto;
import ${packageName}.po.${dbDto.className}Po;
import ${packageName}.service.${dbDto.className}Service;
import ${packageName}.mapper.${dbDto.className}Mapper;
import ${packageName}.repository.${dbDto.className}Repository;
import org.springframework.stereotype.Service;
import com.devilvan.betrice.util.UCopy;

import javax.annotation.Resource;
import java.util.List;

/**
* @author ${author}
* @Description ${dbDto.comment} 业务逻辑类
* @date ${date}
*/
@Service
public class ${dbDto.className}ServiceImpl extends ServiceImpl<${dbDto.className}Mapper, ${dbDto.className}Po> implements ${dbDto.className}Service {
    @Resource(name = "${dbDto.className?uncap_first}Repository")
    private ${dbDto.className}Repository ${dbDto.className?uncap_first}Repository;

    @Override
    public ${dbDto.className}Po saveUpdate(${dbDto.className}Dto ${dbDto.className?uncap_first}Dto) {
        ${dbDto.className}Po ${dbDto.className?uncap_first}Po = new ${dbDto.className}Po();
        UCopy.fullCopy(${dbDto.className?uncap_first}Dto, ${dbDto.className?uncap_first}Po);
        return ${dbDto.className?uncap_first}Repository.saveAndFlush(${dbDto.className?uncap_first}Po);
    }

    @Override
    public List<${dbDto.className}Po> saveUpdateBatch(List<${dbDto.className}Dto> list) {
        List<${dbDto.className}Po> ${dbDto.className?uncap_first}PoList = UCopy.fullCopyCollections(list, ${dbDto.className}Po.class);
        return ${dbDto.className?uncap_first}Repository.saveAllAndFlush(${dbDto.className?uncap_first}PoList);
    }
}
